import { _decorator, Component, Node } from 'cc';
const { ccclass } = _decorator;

const OUTOFBOUNCE = 50

@ccclass('EnemyPlan')
export class EnemyPlane extends Component {
    
    private _enemySpeed = 0;

    update(deltaTime: number) {
        const pos = this.node.position
        const movpos = pos.z + this._enemySpeed
        this.node.setPosition(pos.x, pos.y, movpos)
        // 超出屏幕自动销毁
        if(movpos > OUTOFBOUNCE){
            this.node.destroy()
        }
    }

    public show(speed:number) {
        this._enemySpeed = speed
    }
}


